<template>
  <div>
    <ul>
      <li><router-link to="/contacts/allcontains">All contains </router-link>&nbsp;</li>
      <li><router-link to="/contacts/alice">Alice </router-link>&nbsp;</li>
      <li><router-link to="/contacts/bob">Bob </router-link></li>
    </ul>
    
    <hr>
    <button @click="fn">随机显示</button>
    <router-view></router-view>
   </div>
</template>
 
<script>
export default {
  name: "MyContacts",
  components: {},
  props: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn(){
      const arr=[
        {path:"/contacts/allcontains"},
        {path:"/contacts/alice"},
        {path:"/contacts/bob"}
      ]
      const num=Math.floor(Math.random()*3)
      this.$router.push(arr[num])
    }
  }
};
</script>

<style scoped>
     .router-link-active{
      color:orange;
     }
</style>